#pragma

#include <stdio.h>
#include <pthread.h>
#include <error.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>

#define N 1024
typedef int E;

//阻塞队列 结构体设置
typedef struct {
    E elements[N];  //固定长度的数组，防止需求很多时，占用内存太多，操作系统将进程杀死
    int front;  //队列的头
    int rear;   //下一个数据的存储位置
    int size;   //阻塞队列的长度
    pthread_mutex_t mut;
    pthread_cond_t not_empty;
    pthread_cond_t not_full;
}BlockQ;

BlockQ* blockq_create(void);
void block_destory(BlockQ* q);

bool block_empty(BlockQ* q);
bool block_full(BlockQ* q);
void block_push(BlockQ* q, E val);
E block_pop(BlockQ* q);
E block_peek(BlockQ* q);
